<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<base href="<%=basePath%>">
		
		<meta charset="utf-8" />
		<title></title>
		
		<!-- basic styles -->
		<link href="css/bootstrap.min.css" rel="stylesheet" />
		<link href="css/bootstrap-responsive.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="css/font-awesome.min.css" />
		<!--[if IE 7]>
		  <link rel="stylesheet" href="css/font-awesome-ie7.min.css" />
		<![endif]-->
		<!-- page specific plugin styles -->
		
		<!-- 下拉框-->
		<link rel="stylesheet" href="css/chosen.css" />
		
		<!-- ace styles -->
		<link rel="stylesheet" href="css/ace.min.css" />
		<link rel="stylesheet" href="css/ace-responsive.min.css" />
		<link rel="stylesheet" href="css/ace-skins.min.css" />
		<link rel="stylesheet" href="css/datepicker.css" /><!-- 日期框 -->
		<style type="text/css">
		#zhongxin{
		  margin: 20px;
		  background-color:#E8CCFF;
		  padding: 20px;
		  text-align: center;
		  
		}
		 h4{
		  margin:0px auto 20px;
		  
		}
		input{width:200px;}
		td{
		width:500px;
		}
		td div{
		 width: 100px;
		 float: left;
		 font-weight: bold;
		 
		}
		#list{
		  margin: 20px;
		  background-color:#BBFFEE;
		  padding: 20px;
		  text-align: center;
		  
		}
		#table_report{
		margin-bottom: 0px;
		}
		#table_report tr th{
		text-align: center;
		}
		.message{
		color:black;
		}
	    .erroMessage{
		color:red;
		}		
		</style>

	</head>
<body>
	<div id="breadcrumbs">
	
	<ul class="breadcrumb">
		<li><i class="icon-home"></i> <a href="<%=basePath%>/examinationcontroller/list.do">考点管理</a><span class="divider"><i class="icon-angle-right"></i></span></li>
		<li class="active">考点信息详情管理</li>
	</ul><!--.breadcrumb-->
	
	<div id="nav-search">
	</div><!--#nav-search-->
	
	</div><!--#breadcrumbs-->
	<!-- 此表单用于nextpag -->
	<form action="examinationcontroller/goEdit.do">
	<input type="hidden" name="EXAMINATIONCONTROLLER_ID"  value="${pd.EXAMINATIONCONTROLLER_ID}"/>
	
	</form>
	<form action="examinationcontroller/${msg }.do" name="Form" id="Form" method="post">
		<input type="hidden" name="EXAMINATIONCONTROLLER_ID" id="EXAMINATIONCONTROLLER_ID" value="${pd.EXAMINATIONCONTROLLER_ID}"/>
		<input type="hidden" name="submitFlag" id="submitFlag" value=""/>
		<div id="zhongxin">
		<h4>考点信息表单</h4>
		<c:choose>
		  <c:when test="${empty erroMessage}">
		     <p class="message">${message }</p>
		  </c:when>
		  <c:otherwise>
		      <p class="erroMessage">${erroMessage }</p>
		  </c:otherwise>
		</c:choose>
		<table>
			<tr>
			    <td><div>考点编码:</div><input type="text" name="EXAMINATIONNUM" id="EXAMINATIONNUM" value="${pd.EXAMINATIONNUM}" maxlength="32" placeholder="这里输入考点编码" title="考点编码"/></td>
				<td><div>考点名称:</div><input type="text" name="EXAMINATIONNAME" id="EXAMINATIONNAME" value="${pd.EXAMINATIONNAME}" maxlength="32" placeholder="这里输入考点名称" title="考点名称"/></td>
				<td><div>考点名称中文:</div><input type="text" name="EXAMINATIONNAMECN" id="EXAMINATIONNAMECN" value="${pd.EXAMINATIONNAMECN}" maxlength="32" placeholder="这里输入考点名称中文" title="考点名称中文"/></td>
			</tr>
			<tr>
				<td><div>考点地址:</div><input type="text" name="ADDRESS" id="ADDRESS" value="${pd.ADDRESS}" maxlength="32" placeholder="这里输入考点地址" title="考点地址"/></td>
				<td><div>考点电话:</div><input type="text" name="PHONE" id="PHONE" value="${pd.PHONE}" maxlength="32" placeholder="这里输入考点电话" title="考点电话"/></td>
				<td><div>邮政编码:</div><input type="text" name="ZIPCODE" id="ZIPCODE" value="${pd.ZIPCODE}" maxlength="32" placeholder="这里输入邮政编码" title="邮政编码"/></td>
			</tr>
			<tr>
				<td><div>考点开启时间:</div><input class="span2 date-picker" name="EXBEGINTIME" id="EXBEGINTIME" value="${pd.EXBEGINTIME}" type="text" data-date-format="yyyy-mm-dd" readonly="readonly" placeholder="考点开启时间" title="考点开启时间"/></td>
				<td><div>考点结束时间:</div><input class="span2 date-picker" name="EXENDTIME" id="EXENDTIME" value="${pd.EXENDTIME}" type="text" data-date-format="yyyy-mm-dd" readonly="readonly" placeholder="考点结束时间" title="考点结束时间"/></td>
			</tr>	
		</table>
		 <div>
            <a class="btn btn-mini btn-primary" onclick="save();">保存</a>
	        <a class="btn btn-mini btn-primary" onclick="submit();">提交</a>
            <a class="btn btn-mini btn-danger" href="<%=basePath%>/examinationcontroller/list.do?">取消</a>		 
		 </div>
		</div>
	</form>
	    <div id="list">
	    <h4>考場信息列表</h4>
	  
		<table id="table_report" class="table table-striped table-bordered table-hover">
				
				<thead>
					<tr>
						<th class="center" style="width:30px;">
						<label><input type="checkbox" id="zcheckbox" /><span class="lbl"></span></label>
						</th>
						<th>序号</th>
						<th>考点ID</th>
						<th>科目id</th>
						<th>考场名称</th>
						<th>考场名称中文</th>
						<th>考场编码</th>
						<th>考场状态</th>
						<th>考试开始时间</th>
						<th>操作</th>
					</tr>
				</thead>
		<tbody>
				<!-- 开始循环 -->	
				<c:choose>
					<c:when test="${not empty varList}">
						
						<c:forEach items="${varList}" var="var" varStatus="vs">
									
							<tr>
								<td class='center' style="width: 30px;">
									<label><input type='checkbox' name='ids' value="${var.EXAMINATIONROOMDETILLIST_ID}" /><span class="lbl"></span></label>
								</td>
								<td class='center' style="width: 30px;">${vs.index+1}</td>
										<td>${var.EXAMINATIONID}</td>
										<td>${var.COURSEID}</td>
										<td>${var.ROOMNAME}</td>
										<td>${var.ROOMNAMECN}</td>
										<td>${var.ROOMNUM}</td>
										<td>${var.STATE}</td>
										<td>${var.ROOMBEGINTIME}</td>
								<td style="width: 30px;" class="center">
									<div class='hidden-phone visible-desktop btn-group'>
										<a class='btn btn-mini btn-info' title="编辑" onclick="editListDetail('${var.EXAMINATIONROOMDETILLIST_ID}');"><i class='icon-edit'></i></a>
                                        <a class='btn btn-mini btn-danger' title="删除" onclick="delListDetail('${var.EXAMINATIONROOMDETILLIST_ID}');"><i class='icon-trash'></i></a>
									</div>
								</td>
							</tr>
						</c:forEach>
						
					</c:when>
					<c:otherwise>
						<tr class="main_info">
							<td colspan="100" class="center">没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
				</tbody>
			</table>
			<div class="pagination" style="padding-top: 0px;margin-top: 0px;text-align: right;">${page.pageStr}</div>
			<div class="pagination" style="padding-top: 0px;margin-top: -60px;text-align: right; float: left;"><a class="btn btn-small btn-success" onclick="addListDetail('${pd.EXAMINATIONCONTROLLER_ID}');">新增</a>
					<a class="btn btn-small btn-danger" onclick="makeAll('确定要删除选中的数据吗?');" title="批量删除" ><i class='icon-trash'></i></a></div>

	    </div>
		<!-- 引入 -->
	    <script type="text/javascript" src="js/jquery-1.7.2.js"></script>
	    <!--引入弹窗组件start-->
		<script type="text/javascript" src="js/attention/zDialog/zDrag.js"></script>
		<script type="text/javascript" src="js/attention/zDialog/zDialog.js"></script>
		<!--引入弹窗组件end-->
		<script type="text/javascript">window.jQuery || document.write("<script src='js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script src="js/bootstrap.min.js"></script>
		<script src="js/ace-elements.min.js"></script>
		<script src="js/ace.min.js"></script>
		<script type="text/javascript" src="js/chosen.jquery.min.js"></script><!-- 下拉框 -->
		<script type="text/javascript" src="js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		<script type="text/javascript" src="js/bootbox.min.js"></script><!-- 确认窗口 -->
		<script type="text/javascript" src="js/jquery.tips.js"></script><!--提示框-->
		<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript">

    //校验表单
    function verificationForm(){
    	if($("#EXAMINATIONNUM").val()==""){
			$("#EXAMINATIONNUM").tips({
				side:3,
	            msg:'请输入考点编码',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#EXAMINATIONNUM").focus();
			return false;
		}
		if($("#EXAMINATIONNAME").val()==""){
			$("#EXAMINATIONNAME").tips({
				side:3,
	            msg:'请输入考点名称',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#EXAMINATIONNAME").focus();
			return false;
		}
		if($("#EXAMINATIONNAMECN").val()==""){
			$("#EXAMINATIONNAMECN").tips({
				side:3,
	            msg:'请输入考点名称中文',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#EXAMINATIONNAMECN").focus();
			return false;
		}
		if($("#ADDRESS").val()==""){
			$("#ADDRESS").tips({
				side:3,
	            msg:'请输入考点地址',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#ADDRESS").focus();
			return false;
		}
		if($("#PHONE").val()==""){
			$("#PHONE").tips({
				side:3,
	            msg:'请输入考点电话',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#PHONE").focus();
			return false;
		}
		if($("#ZIPCODE").val()==""){
			$("#ZIPCODE").tips({
				side:3,
	            msg:'请输入邮政编码',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#ZIPCODE").focus();
			return false;
		}
		if($("#EXBEGINTIME").val()==""){
			$("#EXBEGINTIME").tips({
				side:3,
	            msg:'请输入考点开启时间',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#EXBEGINTIME").focus();
			return false;
		}
		if($("#EXENDTIME").val()==""){
			$("#EXENDTIME").tips({
				side:3,
	            msg:'请输入考点结束时间',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#EXENDTIME").focus();
			return false;
		}
		return true;
    }
	
	//保存
	function save(){
		var flag =verificationForm();
		if(flag){
		$("#submitFlag").attr("value","2");
		$("#Form").submit();
		}
	}
	
	//提交
	function submit(){
		var flag =verificationForm();
		if(flag){
		$("#submitFlag").attr("value","1");
		$("#Form").submit();
		}
	}	
	
</script>
		<script type="text/javascript">
		$(window.parent.hangge());
		//新增
		function addListDetail(EXAMINATIONCONTROLLER_ID){
			if(EXAMINATIONCONTROLLER_ID==undefined||EXAMINATIONCONTROLLER_ID==null||EXAMINATIONCONTROLLER_ID=='' ){
				alert("请先保存考点信息");
				return;
			}
			
			 window.parent.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="新增";
			 diag.URL = '<%=basePath%>/examinationcontroller/goListAdd.do?EXAMINATIONCONTROLLER_ID='+EXAMINATIONCONTROLLER_ID;
			 diag.Width = 450;
			 diag.Height = 355;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 if('${page.currentPage}' == '0'){
						 window.parent.jzts();
						 setTimeout("self.location.reload()",100);
					 }else{
						 nextPage(${page.currentPage});
					 }
				}
				diag.close();
			 };
			 diag.show();
		}		
		
		//修改
		function editListDetail(Id){
			 window.parent.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="编辑";
			 diag.URL = '<%=basePath%>/examinationcontroller/goListEdit.do?EXAMINATIONROOMDETILLIST_ID='+Id;
			 diag.Width = 450;
			 diag.Height = 355;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 nextPage(${page.currentPage});
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//删除
		function delListDetail(Id){
			bootbox.confirm("确定要删除吗?", function(result) {
				if(result) {
					var url = "<%=basePath%>/examinationcontroller/deleteListDetail.do?EXAMINATIONROOMDETILLIST_ID="+Id+"&tm="+new Date().getTime();
					$.ajax({
						　url: url,
					　        　type: "GET",
					  　dataType:'text',
					　　success:function(data){
						　　	if(data=="success"){
						　nextPage(${page.currentPage});
						　　		}
						}
					 });
				}
			});			
		}
		</script>
		
		<script type="text/javascript">
		
		$(function() {
			
			//下拉框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			
			//日期框
			$('.date-picker').datepicker();
			
			//复选框
			$('table th input:checkbox').on('click' , function(){
				var that = this;
				$(this).closest('table').find('tr > td:first-child input:checkbox')
				.each(function(){
					this.checked = that.checked;
					$(this).closest('tr').toggleClass('selected');
				});
					
			});
			
		});
		
		
		//批量操作
		function makeAll(msg){
			bootbox.confirm(msg, function(result) {
				if(result) {
					var str = '';
					for(var i=0;i < document.getElementsByName('ids').length;i++)
					{
						  if(document.getElementsByName('ids')[i].checked){
						  	if(str=='') str += document.getElementsByName('ids')[i].value;
						  	else str += ',' + document.getElementsByName('ids')[i].value;
						  }
					}
					if(str==''){
						bootbox.dialog("您没有选择任何内容!", 
							[
							  {
								"label" : "关闭",
								"class" : "btn-small btn-success",
								"callback": function() {
									//Example.show("great success");
									}
								}
							 ]
						);
						
						$("#zcheckbox").tips({
							side:3,
				            msg:'点这里全选',
				            bg:'#AE81FF',
				            time:8
				        });
						
						return;
					}else{
						if(msg == '确定要删除选中的数据吗?'){
							$.ajax({
								type: "POST",
								url: '<%=basePath%>/examinationcontroller/deleteListDetailAll.do?tm='+new Date().getTime(),
						    	data: {DATA_IDS:str},
								dataType:'json',
								//beforeSend: validateData,
								cache: false,
								success: function(data){
									 $.each(data.list, function(i, list){
											nextPage(${page.currentPage});
									 });
								}
							});
						}
					}
				}
			});
		}
		</script>		
		<script type="text/javascript" src="js/jquery.cookie.js"></script>
</body>
</html>